import StudentPaperModel from "../models/StudentPaperModel";


export default class StudentPaperDao {

  static async create(data: any) {
    data.answers = JSON.stringify(data.answers)

    const result = await StudentPaperModel.create(data)
    return result.toJSON()
  }

  /**
   * 查看一个试卷的考生数量
   * @param id 
   */
  static async findExaminationCountById(id: string) {
    const result = await StudentPaperModel.count({
      where: {
        test_paper_id: id
      }
    })

    return {
      id,
      count: result
    }
  }

}